<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="webroot" value="${pageContext.request.contextPath}" />
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>添加成员</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${webroot}/static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${webroot}/static/css/public.css" media="all" />
	<link rel="stylesheet" href="${webroot}/static/css/topdiv.css" media="all" />
	<style type="text/css">
	.layui-col-xs12 {
    width: 80%;
    }
    .layui-form-select {
     position: relative;
   	 width: 275px;
     }
    .layui-input, .layui-textarea {
    display: block;
    width: 275px;
    padding-left: 10px;
	}
}
	</style>
</head>
<body class="childrenBody">
<br><br>
<form class="layui-form" style="width:80%;">
	<input type="hidden" id="id" name="id" value="${parameter.id}" />
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label"><span style="color:red;">*</span>名称:</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input word" lay-verify="required" placeholder="请输入名称" value="${parameter.word}">
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label"><span style="color:red;">*</span>拼音:</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input pinyin" lay-verify="required" placeholder="请输入拼音" value="${parameter.pinyin}">
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<div class="layui-input-block">
			<button class="layui-btn" lay-submit="" lay-filter="addUser">提交</button>	
		</div>
	</div>
</form>
<script type="text/javascript" src="${webroot}/static/layui/layui.js"></script>
<script src="${webroot}/static/js/jquery-3.2.1.min.js" charset="utf-8"></script>
<script>
layui.use(['form','layer','laydate'],function(){
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table;
    
    
    form.on("submit(addUser)",function(data){
    	var url = '';
    	if($("#id").val() != ""){
    		url = '${webroot}/parameter/update';
    	}else{
    		url = '${webroot}/parameter/insert';
    	}
        //弹出loading
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        // 实际使用时的提交信息
        $.post(url,{
             id : $("#id").val(),  //登录名
             word : $(".word").val(),
             pinyin : $(".pinyin").val()
         },function(res){
        	 var data=JSON.parse(res);
        	 if(data.success){
        		top.layer.close(index);
  	            top.layer.msg("操作成功"); 
                window.parent.layer.closeAll();
  	         /*    setTimeout(function(){window.parent.layer.closeAll();},2000); */
        	 }else{
        		 top.layer.msg(data.message);
        	 }
        })
        return false;
    })
})

</script>
</body>
</html>